package com.example.apple.ddhr_new.utils;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.example.apple.ddhr_new.R;

import androidx.annotation.DrawableRes;

public class ImageViewUtil {
    public  static void loadImage(String url, ImageView target, Context context){
        Glide.with(context).load(url).into(target);
    }
    public  static void loadImage(String url, ImageView target, Context context,@DrawableRes int placeHolder){
        RequestOptions options =new RequestOptions();
        options.placeholder(placeHolder);

        Glide.with(context).load(url).apply(options).into(target);
    }
    public  static void loadImageCorner(String url, ImageView target, Context context,int corner,@DrawableRes int placeHolder){
        //设置图片圆角角度
            RoundedCorners roundedCorners= new RoundedCorners(corner);
            RequestOptions options=RequestOptions.bitmapTransform(roundedCorners);
            options.placeholder(placeHolder);
            Glide.with(context).load(url).apply(options).into(target);
    }
    public  static void loadImageCorner(String url, ImageView target, Context context){
        loadImageCorner(url,target,context,10, R.drawable.morentouxiang);
    }
    public  static void loadImageCorner(String url, ImageView target, Context context,@DrawableRes int placeHolder){
        loadImageCorner(url,target,context,10,placeHolder);
    }
    public  static void loadCircleImage(String url, ImageView target, Context context ){
        //设置图片圆角角度



        RequestOptions options=RequestOptions.bitmapTransform(new CircleCrop()).override(300, 300);
        options.placeholder(R.drawable.icon_default);
        Glide.with(context).load(url).apply(options).into(target);
    }
}
